import { Router } from 'express';
import <%= businessName %>Controller from '@/controllers/<%= moduleName %>/<%= businessName %>.controller';
import { authMiddleware } from '@/middlewares/auth.middleware';
import { permissionMiddleware } from '@/middlewares/permission.middleware';
import { controller } from '@/utils/router/route.utils';

const router = Router();

// 可选择两种路由注册方式：直接方式或controller工具方式
// 方式一：直接注册路由（适用于简单场景）

// 查询<%= functionName %>列表
router.get('/list', 
  authMiddleware, 
  permissionMiddleware('<%= permissionPrefix %>:list'), 
  <%= businessName %>Controller.list
);

// 导出<%= functionName %>数据
router.post('/export', 
  authMiddleware, 
  permissionMiddleware('<%= permissionPrefix %>:export'), 
  <%= businessName %>Controller.export
);

// 获取<%= functionName %>详细信息
router.get('/:id', 
  authMiddleware, 
  permissionMiddleware('<%= permissionPrefix %>:query'), 
  <%= businessName %>Controller.getInfo
);

// 新增<%= functionName %>
router.post('/', 
  authMiddleware, 
  permissionMiddleware('<%= permissionPrefix %>:add'), 
  <%= businessName %>Controller.add
);

// 修改<%= functionName %>
router.put('/', 
  authMiddleware, 
  permissionMiddleware('<%= permissionPrefix %>:edit'), 
  <%= businessName %>Controller.edit
);

// 删除<%= functionName %>
router.delete('/:ids', 
  authMiddleware, 
  permissionMiddleware('<%= permissionPrefix %>:remove'), 
  <%= businessName %>Controller.remove
);

/* 
// 方式二：使用controller工具方式注册（推荐用于复杂场景）
// 查询<%= functionName %>列表
controller(
  router,
  '/list',
  <%= businessName %>Controller,
  'get',
  'list',
  [authMiddleware, permissionMiddleware('<%= permissionPrefix %>:list')]
);

// 导出<%= functionName %>数据
controller(
  router,
  '/export',
  <%= businessName %>Controller,
  'post',
  'export',
  [authMiddleware, permissionMiddleware('<%= permissionPrefix %>:export')]
);

// 获取<%= functionName %>详细信息
controller(
  router,
  '/:id',
  <%= businessName %>Controller,
  'get',
  'getInfo',
  [authMiddleware, permissionMiddleware('<%= permissionPrefix %>:query')]
);

// 新增<%= functionName %>
controller(
  router,
  '/',
  <%= businessName %>Controller,
  'post',
  'add',
  [authMiddleware, permissionMiddleware('<%= permissionPrefix %>:add')]
);

// 修改<%= functionName %>
controller(
  router,
  '/',
  <%= businessName %>Controller,
  'put',
  'edit',
  [authMiddleware, permissionMiddleware('<%= permissionPrefix %>:edit')]
);

// 删除<%= functionName %>
controller(
  router,
  '/:ids',
  <%= businessName %>Controller,
  'delete',
  'remove',
  [authMiddleware, permissionMiddleware('<%= permissionPrefix %>:remove')]
);
*/

export default router; 